--TEST--
bool MySQLndUhConnection::close(resource $connection, int $close_type)
--SKIPIF--
<?php require_once('skipif.inc'); ?>
--FILE--
<?php
	require_once('config.inc');

	/* WARNING - PHP will leak and/or crash if you do not call close() !! */

	class proxy extends MySQLndUhConnection {
		public function close($res, $close_type) {
			printf("%s(%s)\n", __METHOD__, var_export(func_get_args(), true));
			var_dump($ret = parent::close($res, $close_type));
			var_dump(close_type_to_string($close_type));
			return $ret;
		}
	}

	class proxy2 extends MySQLndUhConnection {
		public function close($res, $close_type) {
			var_dump(close_type_to_string($close_type));
			parent::close($res, $close_type);
			return -1;
		}
	}

	class proxy3 extends MySQLndUhConnection {
		public function close($res, $close_type) {
			var_dump(close_type_to_string($close_type));
		}
	}

	function close_type_to_string($close_type) {
		$mapping = array(
			MYSQLND_UH_MYSQLND_CLOSE_DISCONNECTED => "MYSQLND_UH_MYSQLND_CLOSE_DISCONNECTED",
			MYSQLND_UH_MYSQLND_CLOSE_EXPLICIT => "MYSQLND_UH_MYSQLND_CLOSE_EXPLICIT",
			MYSQLND_UH_MYSQLND_CLOSE_IMPLICIT => "MYSQLND_UH_MYSQLND_CLOSE_IMPLICIT",
			MYSQLND_UH_MYSQLND_CLOSE_LAST => "MYSQLND_UH_MYSQLND_CLOSE_IMPLICIT"
		);
		return (isset($mapping[$close_type])) ? $mapping[$close_type] : 'unknown';
	}

	$conn = mysqlnd_uh_test\connect::mysqli();
	mysqlnd_uh_test\query_test::mysqli($conn);

	mysqlnd_uh_set_connection_proxy(new proxy());

	$conn->close();

	$conn = mysqlnd_uh_test\connect::mysqli();
	mysqlnd_uh_test\query_test::mysqli($conn);
	unset($conn);

	$conn = mysqlnd_uh_test\connect::mysqli();
	$conn = 2;

	$conn = mysqlnd_uh_test\connect::mysqli();
	mysqlnd_uh_set_connection_proxy(new proxy2());
	$conn->close();

	mysqlnd_uh_set_connection_proxy(new proxy2());
	$conn = mysqlnd_uh_test\connect::mysqli();

	print "done!\n";
?>
--EXPECTF--
proxy::close(array (
  0 => NULL,
  1 => 0,
))
bool(true)
string(33) "MYSQLND_UH_MYSQLND_CLOSE_EXPLICIT"
proxy::close(array (
  0 => NULL,
  1 => 0,
))
bool(true)
string(33) "MYSQLND_UH_MYSQLND_CLOSE_EXPLICIT"
proxy::close(array (
  0 => NULL,
  1 => 0,
))
bool(true)
string(33) "MYSQLND_UH_MYSQLND_CLOSE_EXPLICIT"
string(33) "MYSQLND_UH_MYSQLND_CLOSE_EXPLICIT"

Warning: mysqli::close(): (MySQLnd User Handler) The method MySQLndUhConnection::close() did not return a boolean value as it should in %s on line %d
done!
string(33) "MYSQLND_UH_MYSQLND_CLOSE_EXPLICIT"

Warning: Unknown: (MySQLnd User Handler) The method MySQLndUhConnection::close() did not return a boolean value as it should in Unknown on line %d